-
Notifications
You must be signed in to change notification settings - Fork 8
feat: add diff and get command for the registry #1851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
9771903 to
6f57947
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General comment: dre registry is used in a lot of our tooling (that isn't all in this repo sadly) and changing its interface will demand a lot of additional work that we may not even see now. I suggest one of the following:
- Leave current
dre registryas is, extract the things that you need in a module and make your own new command for the diff - Somehow keep the old behavior as is
dre registry> dumps the registry
Personally I think that the first one is easier
I'll let @pietrodimarco-dfinity finish the review as he has more insights into what is needed. These are just styling comments.
3bdfa14 to
6693ae8
Compare
6693ae8 to
19985f6
Compare
| // Ensure local registry is initialized/synced to have content available | ||
| // (no-op in offline mode) | ||
| let _ = ctx.registry_with_version(None).await; | ||
| // Reorder if needed to ensure increasing order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure reordering is expected by clients...I would panic if that's the case
| } else if version_1 > 0 && version_2 > 0 { | ||
| from_version = version_1_u64; | ||
| to_version = version_2_u64; | ||
| } else if version_1 * version_1 < 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be version_1 * version_2 right?
| anyhow::bail!("Cannot mix positive version numbers and negative indices"); | ||
| } else if version_1 == 0 || version_2 == 0 { | ||
| anyhow::bail!("Version 0 is not supported"); | ||
| } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unreachable I believe. We can probably simplify:
f version_1 * version_2 < 0 {
anyhow::bail!("Cannot mix positive version numbers and negative indices");
} else if version_1 > 0 {
....
} else if version_1 < 0 {
....
} else
| ) | ||
| } | ||
|
|
||
| pub fn create_from_args( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new here is probably ideal here. Instead of the enum VersionFillMode I would create two methods new_from_start and new_to_end or similar. With an additional method grouping common functionalities
| } | ||
|
|
||
| impl VersionRange { | ||
| pub fn get_from(&self) -> u64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just make them pub instead
Backwards compatibility:
Introduction of three new subcommands:
Get: Show aggregated registry data
History: Show registry data of specified versions
Diff: Show diff of the data between two aggregated versions
Manual Testing: